//
//  LMNetworkError.swift
//  LMNetwork
//
//  Created by zhuo on 2018/9/13.
//

import Foundation
import Moya

public enum LMNetworkError: Swift.Error {
    /// 网络等错误
    case httpStatusCode(Response)
    // 解析json错误
    case jsonMapping(Any?)
    // 服务返回的code
    case serverStatueCode(code: Int, message: String?)
    case other(Any?)
}

extension LMNetworkError {
    static func error(code: Int, msg: String? = nil) -> LMNetworkError {
        let info: [String: Any?] = ["code": code, "msg": msg]
        return LMNetworkError.other(info as Any?)
    }
}
